package Game;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;

import org.rtscup.core.Map;
import org.rtscup.core.Unit;
import org.rtscup.core.util.Memory;

import Basic.AStar;
import Basic.Tiles;

public class Blackboard2 {

	private HashMap<Integer, Integer> intendingTiles;
	public AStar aStar;
	public Tiles tiles;

	public int actingSoldierCount;

	public int choosenEnemy;
	public int choosenEnemyBuilding; 
	public boolean hasMoreEnemies;
	
	public boolean canCure = false;
	public boolean isAttackingEnemy = false;
	
	public List<Unit> enemies;
	public List<Unit> allies;
	public Memory memory;
	
	private static Blackboard2 instance;

	public static Blackboard2 getInstance(Map map, Unit agent, Long[] obstacles) {
		if (instance == null) {
			instance = new Blackboard2(map, agent, obstacles);
		}
		return instance;
	}

	private Blackboard2(Map map, Unit agent, Long[] obstacles) {
		this.tiles = new Tiles(map.getWidth(), map.getHeight(), map.getWidth() / agent.getWidth(), map.getHeight() / agent.getHeight(), obstacles);
		this.aStar = new AStar(tiles);

		this.intendingTiles = new HashMap<Integer, Integer>();
		this.actingSoldierCount = 0;
		this.choosenEnemy = -1;
		this.hasMoreEnemies = true;
		this.canCure = false;
	}

	public void putIntending(Integer key, Integer intendingPoint) {
		this.intendingTiles.put(key, intendingPoint);
	}

	public Collection<Integer> getIntendings(Integer key) {
		HashMap<Integer, Integer> temp = new HashMap<Integer, Integer>(this.intendingTiles);
		temp.remove(key);
		return temp.values();
	}

	public boolean hasAvaiableBuilding() {
		return true;
	}
}
